﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Restaurant.DTO;
using Restaurant.BUS;

namespace Restaurant
{
    public partial class frmChiTietDoanhThu : Form
    {
        private DoanhThuService dtService = new DoanhThuService();
        int MaNH;
        DateTime Ngay;

        public frmChiTietDoanhThu()
        {
            InitializeComponent();
        }
        
        public frmChiTietDoanhThu(int maNH, DateTime ngay)
        {
            MaNH = maNH;
            Ngay = ngay;
            InitializeComponent();
        }

        public void LoadChiTietDoanhThu(DataTable dbtab)
        {
            for (int i = 0; i < dbtab.Rows.Count; i++)
            {
                DataRow dbrow = dbtab.Rows[i];
                ListViewItem liv = new ListViewItem();
                liv.Text=dbrow["MaNH"].ToString();
                liv.SubItems.Add(dbrow["TenNH"].ToString());
                liv.SubItems.Add(dbrow["NgayTongKet"].ToString());
                liv.SubItems.Add(dbrow["TongTienBan"].ToString());
                lvDanhSachDoanhThu.Items.Add(liv);
            }
        }

        

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnThongTinCTHD_Click(object sender, EventArgs e)
        {
            //frmChiTietHoaDon _frmCTHD = new frmChiTietHoaDon();
            //_frmCTHD.btnThanhToan.Visible = false;
            //_frmCTHD.Show();
            //MessageBox.Show(DateTime.Parse(lvDanhSachDoanhThu.FocusedItem.SubItems[2].Text).ToString());
            frmHoaDon frmhd = new frmHoaDon(MaNH,DateTime.Parse(lvDanhSachDoanhThu.FocusedItem.SubItems[2].Text));
            frmhd.Show();
        }

        private void frmChiTietDoanhThu_Load(object sender, EventArgs e)
        {
            DataTable dtbdtb = dtService.LoadDoanhThuNgayNH(MaNH, Ngay);
            LoadChiTietDoanhThu(dtbdtb);
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }
    }
}
